/*
 * Transform.h
 *
 *  Created on: 1-dec.-2013
 *      Author: Axel
 */

#ifndef TRANSFORM_H_
#define TRANSFORM_H_

#include "algebraBasic.h"

class Transform {
public:
	Transform() {
        m_scale      = Vector3f(1.0f, 1.0f, 1.0f);
        m_worldPos   = Vector3f(0.0f, 0.0f, 0.0f);
        m_rotateInfo = Vector3f(0.0f, 0.0f, 0.0f);
    }

    void Scale(float ScaleX, float ScaleY, float ScaleZ) {
        m_scale.x = ScaleX;
        m_scale.y = ScaleY;
        m_scale.z = ScaleZ;
    }

    void WorldPos(float x, float y, float z) {
        m_worldPos.x = x;
        m_worldPos.y = y;
        m_worldPos.z = z;
    }

    void Rotate(float RotateX, float RotateY, float RotateZ) {
        m_rotateInfo.x = RotateX;
        m_rotateInfo.y = RotateY;
        m_rotateInfo.z = RotateZ;
    }

    //void SetPerspectiveProj(float left, float right, float top, float bottom, float zNear, float zFar) {
    void SetPerspectiveProj(float FOV, float width, float height, float zNear, float zFar) {
    	/*
    	m_persProj.right = right;
    	m_persProj.left = left;
    	m_persProj.top = top;
    	m_persProj.bottom = bottom;
    	m_persProj.zNear = zNear;
    	m_persProj.zFar = zFar;
    	*/
        m_persProj.FOV    = FOV;
        m_persProj.Width  = width;
        m_persProj.Height = height;
        m_persProj.zNear  = zNear;
        m_persProj.zFar   = zFar;
        //*/
    }

    const Matrix4f* GetTrans();

    Matrix4f frustum(Matrix4f& m);
    Matrix4f ortho(float left, float right, float bottom, float top, float n, float f);

private:
    void InitScaleTransform(Matrix4f& m) const;
    void InitRotateTransform(Matrix4f& m) const;
    void InitTranslationTransform(Matrix4f& m) const;
    void InitPerspectiveProj(Matrix4f& m) const;

    Vector3f m_scale;
    Vector3f m_worldPos;
    Vector3f m_rotateInfo;

    struct {
    	float right;
    	float left;
    	float top;
    	float bottom;
        float FOV;
        float Width;
        float Height;
        float zNear;
        float zFar;
    } m_persProj;

    Matrix4f m_transformation;
};

#endif /* TRANSFORM_H_ */
